<?php

/**
 * This file is part of the Codizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Codizer Core Team <team@codizer.org>
 * @package     Codizer
 */

function smarty_function_frontend_image($params, &$smarty)
{
	if(!isset($params['file']) || is_null($params['file']) || $params['file'] == "")
	{
		return '';
	}

    require_once $smarty->_get_plugin_filepath('function','html_image');

	$conf = f_loader_Config::getInstance()->getParameters("default");

	$path = URL_RELATIVE.'/themes/'.$conf['frontTheme'].'/frontend/images/'.$params['file'];

    if(isset($params['getOnlyPath']) && $params['getOnlyPath'] == 'true')
    {
        // Get only the relative path to the image
        return $path;
    }
    else
    {
        $params['file'] = substr($path, 1);

        // Create the whole img tag
        return smarty_function_html_image($params, $smarty);
    }

}